$(function () {
    //权限列表初始化
    $("#permission_datagrid").datagrid({
        fit:true,
        url:"/permission/list",
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        striped:true,
        toolbar :"#tb",
        singleSelect:true,
        columns:[[
            {field:"id",title:"编号",hidden:true},
            {field:"name",title:"权限名称",width:100},
            {field:"resources",title:"权限表达式",width:100}
        ]],
    })
})

//加载权限
function load(){
    $.messager.confirm('确认','您确认想要加载权限吗？',function(r){
        if (r){
            $.get("/permission/load",function (data){
                if(data.success){
                    //刷新数据
                    $("#permission_datagrid").datagrid("reload");
                }else{
                    $.messager.alert("温馨提示",data.msg);
                }
            })
        }
    });

}

//列表刷新
function reload(){
    $("#permission_datagrid").datagrid("reload");
}
